pull: Dedup code for checking for > 0 valid results
authorColin Walters <walters@verbum.org>
Sat, 19 Nov 2016 01:22:10 +0000 (20:22 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Mon, 21 Nov 2016 15:55:09 +0000 (15:55 +0000)
We have a public API for this, let's use it internally.

Closes: #589
Approved by: jlebon

src/libostree/ostree-repo-pull.c

index fd35e87a8b40dec3497e941a84017a2dab7fff8c..7a4ccfdbd2dc34671fcdd9e9b59ce412f9199316 100644 (file)
@@ -1086,12 +1086,8 @@ scan_commit_object (OtPullData         *pull_data,
                              "gpg-verify-result",
                              checksum, result);
 
-      if (ostree_gpg_verify_result_count_valid (result) == 0)
-        {
-          g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                       "GPG signatures found, but none are in trusted keyring");
-          goto out;
-        }
+      if (!ostree_gpg_verify_result_require_valid_signature (result, error))
+        goto out;
     }
 
   if (!ostree_repo_load_commit (pull_data->repo, checksum, &commit, &commitstate, error))
@@ -2737,15 +2733,8 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
                                                         NULL,
                                                         cancellable,
                                                         error);
-        if (result == NULL)
+        if (!ostree_gpg_verify_result_require_valid_signature (result, error))
           goto out;
-
-        if (ostree_gpg_verify_result_count_valid (result) == 0)
-          {
-            g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
-                         "GPG signatures found, but none are in trusted keyring");
-            goto out;
-          }
       }
 
     if (pull_data->summary)